package com.dgut.common.mapper;

import com.dgut.common.entity.OrderDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dgut.common.result.CategoryWeightData;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zyq
 * @since 2022-03-13
 */
@Repository
public interface OrderDetailMapper extends BaseMapper<OrderDetail> {


    @Select("select category_name, IFNULL(sum(IFNULL(weight, 0)), 0) from order_detail where create_time between #{beginTime} and #{endTime} group by category_name")
    List<CategoryWeightData> categoryData(Date beginTime, Date endTime);

}
